import java.util.Scanner;

/**
 * 循环打印输入的月份的天数。要有判断输入的月份是否错误的语句
 * @author Lenovo
 *
 */
public class Demo1 {
	public static void main(String[] args) {
		boolean flag = true;
		Scanner sc = new Scanner(System.in);
		while (flag) {
			System.out.println("请输入年月日");
			int year = sc.nextInt();
			int month = sc.nextInt();
			int day = sc.nextInt();
			
			if (!(month > 0 && month < 13)) {
				System.out.println("你输入的月份错误");
				continue;
			}else {
				switch (month) {
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12:
					if (!(day > 0 && day <= 31)) {
						System.out.println("你输入的天数错误");
						continue;
					}
					break;
				case 4:
				case 6:
				case 9:
				case 11:
					if (!(day > 0 && day <= 30)) {
						System.out.println("你输入的天数错误");
						continue;
					}
					break;
				default:
					if (year % 400 == 0 || (year %4 == 0 && year %100 != 0)) {
						if (!(day > 0 && day <= 29)) {
							System.out.println("你输入的天数错误");
							continue;
						}
					}else {
						if (!(day > 0 && day <= 28)) {
							System.out.println("你输入的天数错误");
							continue;
						}
					}
					
					
					break;
				}
			}
			
			System.out.printf("%s年%s月%s日\n",year,month,day);
			System.out.println("是否继续输入?(Y/N)");
			String str = sc.next();
			if ("Y".equalsIgnoreCase(str)) {
				flag = true;
			}else if ("N".equalsIgnoreCase(str)) {
				flag = false;
			}else {
				System.out.println("输入有误");
				flag = false;
			}
			
		}
	}

}
